// Bristleback plugin - Copyright (c) 2010 bristleback.googlecode.com
// ---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
// This library is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of merchantability
// or fitness for a particular purpose.
// You should have received a copy of the GNU Lesser General Public License along
// with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
// ---------------------------------------------------------------------------
package pl.bristleback.server.bristle.actions;

import org.apache.log4j.Logger;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Class containing information about loaded actions.
 * <p/>
 * Created on: 2010-09-03 16:02:05 <br/>
 *
 * @author Wojciech Niemiec
 */
public class ActionsContainer {
  private static Logger log = Logger.getLogger(ActionsContainer.class.getName());

  private Map<String, RemoteActionInformation> actionsMap;

  /**
   * Creates a new empty actions container.
   */
  public ActionsContainer() {
    actionsMap = new HashMap<String, RemoteActionInformation>();
  }

  /**
   * Gets all loaded action wrappers.
   *
   * @return collection of all loaded actions,
   *         wrapped into {@link pl.bristleback.server.bristle.actions.RemoteActionInformation} object.
   */
  public Collection<RemoteActionInformation> getAllActions() {
    return actionsMap.values();
  }

  /**
   * Gets an action wrapper for given action name.
   *
   * @param actionName action name.
   * @return action wrapper if action was found or null otherwise.
   */
  public RemoteActionInformation getAction(String actionName) {
    return actionsMap.get(actionName);
  }

  /**
   * Adds an action wrapper to map. Action name will be used as a key of entry.
   *
   * @param actionInformation action wrapper.
   */
  public void addAction(RemoteActionInformation actionInformation) {
    actionsMap.put(actionInformation.getActionName(), actionInformation);
  }
}
